package edu.ilstu.mind.ise.ccp.impl.disruptor;

import com.lmax.disruptor.EventHandler;

import edu.ilstu.mind.ise.ccp.mindmodule.MindModule;

class MindModuleEventHandler implements EventHandler<MessageEvent> {

	private final MindModule mindModule;
	
	public MindModuleEventHandler(MindModule mindModule) {
		if(mindModule == null) {
			throw new IllegalArgumentException("mindModule cannot be null");
		}
		this.mindModule = mindModule;
	}
	
	@Override
	public void onEvent(MessageEvent event, long sequence, boolean endOfBatch) throws Exception {
		event.process = mindModule.onMessage(event.message);
	}

}
